# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-nestopia
pkgver=1.52.0.41
_realname=Nexus
pkgrel=0
pkgdesc="Nestopia GameClient for XBMC"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.nestopia"
arch="x86_64 aarch64 armv7" # kodi is available only on these architectures
license="GPL-2.0-or-later"
makedepends="cmake kodi-dev samurai"
depends="kodi-game-libretro libretro-nestopia"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.nestopia/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.nestopia-$pkgver-$_realname"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.nestopia/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.nestopia/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.nestopia/game.libretro.nestopia.so
	ln -s /usr/lib/libretro/nestopia_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.nestopia/game.libretro.nestopia.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.nestopia/addon.xml
}

sha512sums="
86b893f699285c7c7e881f31af98109cd7045d03f93a93621d28f969cfae0c22bdc8e431d48a9313755880d8bf27912d8eb872cbd81041fa701aad83f0da7383  kodi-game-libretro-nestopia-1.52.0.41-Nexus.tar.gz
"
